/**
 * 
 */
package cn.haona.game.simb.object.bio;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.HashMap;

import cn.haona.db.RelevanceBean;
import cn.haona.game.simb.comm.util.Util;
import cn.haona.game.simb.object.Persistence;
import cn.haona.game.simb.object.bio.Npc.NpcPO;
import cn.haona.game.simb.object.god.EntityManager;
import cn.haona.game.simb.object.god.MainManager;

/**
 * 战斗者
 * 
 * @author shenhao
 * 
 */
public class Fighter extends Human implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1860598315178551693L;

	/**
	 * 
	 */
	public Fighter() {
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * 创建打斗对象
	 * @param fightEventID TODO
	 * @param humanID
	 * @param humanType
	 * @param humanClass
	 * @return
	 */
	public static Fighter createFighter(Long fightEventID,Long humanID,int humanType, String humanClass)
	{
		Fighter fighter=null;
		
		EntityManager em=MainManager.getInstance().getEntityManager();
		Human human=null;
		try {
			human=(Human)em.getCellInstance(humanClass, humanID.longValue());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		fighter=new Fighter();
		fighter.initPO();
		//复制
		Human.copyParams(human.getHumanPO(), fighter.getHumanPO());
		fighter.getFighterPO().setEventID(fightEventID);
		fighter.getFighterPO().setType(humanType);
		fighter.getFighterPO().setOrgID(humanID);
		//持久化打斗对象
		fighter.getPO().persisMeFirstTime();
		return fighter;
	}
	

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.haona.game.simb.object.Cell#initPO()
	 */
	public void initPO() {
		if (pO == null) {
			pO = new FighterPO();
		}
	}

	/**
	 * 得到UserPO对象
	 * 
	 * @return
	 */
	public FighterPO getFighterPO() {
		return (FighterPO) pO;
	}

	/**
	 * 持久化Figher对象
	 * 
	 * @author shenhao
	 * 
	 */
	public class FighterPO extends PersistenceHuman implements Serializable {
		/**
		 * 
		 */
		private static final long serialVersionUID = 3447559102206070917L;
		final public static String TABLE_NAME = "OPT_FIGHTER";
		final public static String EVENT_ID="FE_ID";
		final public static String TYPE = "FGT_TYPE";
		final public static String ORG_ID = "ORG_ID";// 原型ID
		
		
		//打斗事件ID
		private Long eventID;
		
		// 什么类型的斗殴者
		private Integer type;
		// 玩家
		final public static int TYPE_USER = 0;
		// NPC
		final public static int TYPE_NPC = 1;

		// 原型者的ID
		private Long orgID;

		/**
		 * 设置反射关联
		 * 
		 * @param reflectRelevance
		 */
		public void setReflectRelevance(
				HashMap<String, RelevanceBean> reflectRelevance) {
		    super.setReflectRelevance(reflectRelevance);
		    reflectRelevance.put(EVENT_ID, new RelevanceBean("eventID", EVENT_ID));
		    reflectRelevance.put(TYPE, new RelevanceBean("type", TYPE));
		    reflectRelevance.put(ORG_ID, new RelevanceBean("orgID", ORG_ID));
		}
		
		public boolean cacheMe() {
			// TODO Auto-generated method stub
			return false;
		}


		public Integer getType() {
			return type;
		}

		public void setType(Integer type) {
			this.type = type;
		}

		public Long getOrgID() {
			return orgID;
		}

		public void setOrgID(Long orgID) {
			this.orgID = orgID;
		}

		public Long getEventID() {
			return eventID;
		}

		public void setEventID(Long eventID) {
			this.eventID = eventID;
		}


	}

}
